Skip to main content

mockseries.seasonality.yearly_seasonality

YearlySeasonality#

class YearlySeasonality(PeriodSeasonality)

Realistic yearly seasonality from a set of time/value constraints.

Finest granularity for constraints and generation is microseconds. The interpolation method is PCHIP.

Arguments:

  • time_value_constraints - A dict of {time: value} constraints. The curve will pass through these points. Pass time as a timedelta between 0 days 00:00:00 and 364 days 23:59:59. For instance, {timedelta(days=55): 4.2}` If generation is performed on a leap year, February 29 is approximated as the mean between February 28 and March 1. Ie timdedelta(days=59) always corresponds to March 1 for fitting.
  • utc_offset - The offset from UTC of the time. For instance, if you give constraints with GMT-8 times in mind, pass timedelta(hours=-8). Default behavior considers times are passed as UTC.
  • normalize - transform constraints to a multiplication factor for easy use in multiplicative interactions. Eg: [5, 10, 15] --> [0.5, 1, 1.5].

Examples:

from datetime import timedelta, datetime
from mockseries.seasonality import YearlySeasonality
timeseries = YearlySeasonality({timedelta(days=15): 0.7, timedelta(days=45): 0.8, timedelta(days=75): 0.9, timedelta(days=105): 1.1, timedelta(days=200): 1.4, timedelta(days=340): 2})
timeseries.preview_year(num_years=4)